<!--气泡弹窗的按钮-->
<template>
  <div class="btn-pan-1">
    <Button id="addToGroup" v-if="type==='grp'" :disabled="!canEdit " class="btn1" icon="md-person-add" :title="$t('manage_group_user')" type="info" @click="btnClick('addToGroup')"></Button>
    <Button id="removeUser" v-if="type==='usr'" :disabled="!canEdit || !thisPlatForm" class="btn1" icon="md-remove" :title="$t('remove_user_from_group')" type="info" @click="btnClick('removeUser')"></Button>
    <Button id="clearFromGroup" v-if="type==='grp'" :disabled="!canEdit" class="btn1" icon="md-remove" :title="$t('clear_user_from_group')" type="info" @click="btnClick('clearFromGroup')"></Button>
    <Button id="delGroup" v-if="type==='grp'" :disabled="!canEdit" class="btn1" icon="md-close" :title="$t('delete_group')" type="info" @click="btnClick('delGroup')"></Button>
  </div>
</template>
<script>
import {getLoginUser} from "@/libs/util";
import AuthCheck from "@/api/AuthCheck";
export default {
  name: "ZzdGroupUserTreeButtons",
  props:{
    type:{type: String,default: 'all'}, //grp usr all
    thisPlatForm:{type: Boolean,default:true}, //是否是此平台
  },
  data(){
    return{
      canEdit:false
    }
  },
  methods:{
    btnClick(event){
      /**
       * delGroup 删除群组
       * clearFromGroup 移除设备
       * addToGroup 加入设备
       * removeUser 移除设备
       */
      //console.log(event);
      this.$emit('btnClick', event);

    }
  },
  mounted() {
    const userInfo = getLoginUser();
    const userLoginName=!!userInfo?userInfo.loginName:"";
    //this.canEdit = userLoginName === "admin" || userLoginName === "Admin" || userLoginName === "super";
    this.canEdit = new AuthCheck().commandDispatchGroupTalk();
  }
}
</script>
<style lang="less">
.btn-pan-1 {
  display: flex;
  flex-wrap: wrap;
  margin-left: 0px;
  .btn1 {
    margin-left: 5px;
    margin-bottom: 2px;
  }
}
</style>
